"""
用队列判断括号是否有效
"""

def is_valid_parentheses(s):
    """
    判断括号字符串是否有效：利用队列存储左括号，遇到右括号时匹配
    s：括号字符串，如"()[]{}"
    """
    from collections import deque
    queue = deque()
    mapping = {")": "(", "]": "[", "}": "{"}
    for char in s:
        if char in mapping.values():  # 左括号入队
            queue.append(char)
        elif char in mapping:  # 右括号需匹配队尾左括号
            if not queue or queue.pop() != mapping[char]:
                return False
    return len(queue) == 0  # 最终队列空则有效

# 测试
print(is_valid_parentheses("()[]{}"))  # 输出：True
print(is_valid_parentheses("([)]"))    # 输出：False